<div class="db_left bl">
    <?php $this->load->view('cms/article/side_block'); ?>
</div>
<div class="db_right bl">
    <div id="breadcrumb" class="clearfix mt_10">
        <ul class="h_list no_list_style ah">
            <li><a href="<?php echo site_url('admin/dashboard', true); ?>">Bảng điều khiển</a></li>
            <li class="SecondLast"><a href="<?php echo site_url('admin/cms/comment/index', true); ?>">Quản lý bình luận</a></li>
        </ul>
    </div>
    <div class="std_header auto_height">
        <div class="left">
            <strong>Thao tác</strong>
        </div>
        <div class="right">
            <button type="button" class="gray_btn" onclick="window.location='<?php echo $return_url; ?>'"><span>Trở lại</span></button>
            &nbsp;
            <button class="gray_btn" onclick="window.location='<?php echo site_url('admin/cms/comment/edit', true); ?>'">
                <span>Thêm mới</span>
            </button>
            &nbsp;
            <button class="gray_btn" type="button" onclick="return admin_cms_comment.save_go_back();"><span>Lưu và quay lại</span></button>
            &nbsp;
            <button class="gray_btn" type="submit" onclick="$('#frm_comment').submit();"><span>Lưu và tiếp tục</span></button>
            <?php if (isset($comment->id)) :?>
            &nbsp;
            <button type="button" onclick="admin_cms_comment.confirm_delete(this);" title="Bạn muốn xóa bình luận <?php echo get_field($comment, 'name'); ?>?" action="<?php echo site_url('admin/cms/comment/delete/id/' . $comment->id, true); ?>" class="gray_btn" type="submit"><span>Xóa bình luận</span></button>
            <?php endif; ?>
        </div>
    </div>
    <?php $this->load->view('cms/comment/message'); ?>
    <div id="comment_management">
    <form id="frm_comment" enctype="multipart/form-data" action="<?php echo site_url('admin/cms/comment/save', true); ?>" method="post">
        <input type="hidden" id="go_back" name="go_back" value="0" />
        <input type="hidden" name="data[ip_address]" value="<?php echo get_field($comment, 'ip_address'); ?>" />
        <?php if (isset($comment->id)) :?>
        <input type="hidden" name="id" value="<?php echo $comment->id; ?>" />
            <?php endif; ?>
        <input type="hidden" name="status" value="<?php echo get_field($comment, 'status'); ?>" />
        <div id="tab_store" class="tab_container">
        <ul>
            <li id="active_general"><a href="#tab_general"><span>Thông tin bình luận</span></a></li>
        </ul>
        <div id="tab_general" style="padding-top: 0px !important">
            <div class="form_block">
                <div class="block_header">
                    Thông tin bình luận <?php if (!empty($comment->id)) :?><strong>[<?php echo $comment->title; ?>]</strong><?php endif; ?>
                </div>
                <div class="block_content">
                    <table cellpadding="0px" cellspacing="0px">
                        <?php if (!empty($comment->id)) :?>
                        <tr>
                            <td class="frm_label">ID bình luận(*)</td>
                            <td class="frm_field">
                                <strong><span class="simple_btn">#<?php echo $comment->id; ?></span></strong>
                            </td>
                        </tr>
                        <tr>
                            <td class="frm_label">Thời điểm bình luận(*)</td>
                            <td class="frm_field">
                                <span><?php echo render_date($comment->created_at, 'd/m/y, H:i'); ?> - <?php if (!empty($comment->ip_address)) :?><strong>IP: <span><?php echo $comment->ip_address; ?></span></strong><?php endif; ?>
                            </td>
                        </tr>
                        <?php endif; ?>
                        <tr>
                            <td class="frm_label">Tiêu đề bình luận(*)</td>
                            <td class="frm_field">
                                <input placeholder="Tiêu đề tin" type="text" name="data[title]" value="<?php echo get_field($comment, 'title'); ?>" title="Tiêu đề bình luận cần phải nhập" class="std_input required" />
                            </td>
                        </tr>
                        <tr>
                            <td class="frm_label">Tên người gửi(*)</td>
                            <td class="frm_field">
                                <input placeholder="Tên người gửi" type="text" name="data[name]" value="<?php echo get_field($comment, 'name'); ?>" title="Tên người gửi phải nhập" class="std_input required" />
                            </td>
                        </tr>
                        <tr>
                            <td class="frm_label">Email bình luận(*)</td>
                            <td class="frm_field">
                                <input placeholder="Email bình luận" type="text" name="data[email]" value="<?php echo get_field($comment, 'email'); ?>" title="Bạn chưa nhập đúng định dạng email" class="std_input required email" />
                            </td>
                        </tr>
                        <tr>
                            <td class="frm_label">Duyệt bình luận(*)</td>
                            <td class="frm_field">
                                <label>
                                    <input name="data[is_approved]" class="std_chk" type="checkbox" value="1" <?php if (get_field($comment, 'is_approved') == 1) :?>checked="checked"<?php endif; ?> />
                                    <span>Đã duyệt / Chưa duyệt</span>
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <td class="frm_label">Kiểu bình luận(*)</td>
                            <td class="frm_field">
                                <select name="data[type]" style="width: 200px;">
                                    <?php foreach ($this->cms_comment_model->get_list_types() as $type => $label) :?>
                                    <option value="<?php echo $type; ?>" <?php if (get_field($comment, 'type') == $type) :?>selected="selected"<?php endif; ?>><?php echo $label; ?></option>
                                    <?php endforeach; ?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="frm_label">Nội dung(*)</td>
                            <td class="frm_field">
                                <textarea placeholder="Nội dung bình luận" title="Nội dung bình luận" name="data[content]" class="required"><?php echo get_field($comment, 'content'); ?></textarea>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>

        </div>
        <button type="button" class="gray_btn" onclick="window.location='<?php echo site_url('admin/cms/comment/index', true); ?>'"><span>Trở lại</span></button>
        &nbsp;
        <button class="gray_btn" type="button" onclick="return admin_cms_comment.save_go_back()"><span>Lưu và quay lại</span></button>
        &nbsp;
        <button class="gray_btn" type="submit" onclick="$('#frm_comment').submit();"><span>Lưu và tiếp tục</span></button>
        <?php if (isset($comment->id)) :?>
        &nbsp;
        <button type="button" onclick="admin_cms_comment.confirm_delete(this);" title="Bạn muốn xóa bình luận <?php echo get_field($comment, 'name'); ?>?" action="<?php echo site_url('admin/cms/comment/delete/id/' . $comment->id, true); ?>" class="gray_btn"><span>Xóa bình luận</span></button>
        &nbsp;
            <?php endif; ?>
        <br/><br/>
    </form>
    </div>
</div>
<div class="clearfix"></div>
<script type="text/javascript">
    $("#frm_comment").validate({
       errorLabelContainer: $("#form_error")
    });
    var comment_id = <?php if (isset($comment->id)) :?><?php echo $comment->id; ?><?php else :?>0<?php endif; ?>;
</script>
<script type="text/javascript" src="<?php echo BASE_URL; ?>js/admin/cms/comment/function.js"></script>
